/*************************************
 * Created by WebStorm
 * Author : 菲尔敦
 * QQ邮箱：2891044172@qq.com  手机号：15981761402
 * Created Time :2024/2/6 13:34
 Desc :
 **************************************/
import {unref, computed, watch, ComputedRef, ref} from 'vue';
import {DataTableProps} from 'naive-ui'
export function useLoading(props:ComputedRef<DataTableProps>) {
    const loadingRef = ref<boolean|undefined>(unref(props).loading);
    const getLoading = computed(() => loadingRef.value);
    function setLoading(loading: boolean) {
        loadingRef.value = loading;
    }
    watch(
        () => unref(props).loading,
        (loading) => {
            loadingRef.value = loading;
        }
    );
    return {
        getLoading,
        setLoading
    }
}